function throttle(func, delay) {
    let timerId;
    let lastExecutedTime = 0;

    return function (...args) {
        const currentTime = Date.now();
        const elapsed = currentTime - lastExecutedTime;

        if (elapsed < delay) {
            clearTimeout(timerId);
            timerId = setTimeout(() => {
                lastExecutedTime = currentTime;
                func.apply(this, args);
            }, delay - elapsed);
        } else {
            lastExecutedTime = currentTime;
            func.apply(this, args);
        }
    };
}
export default throttle;